import {RequestParam,HttpRequest} from '@/utils/http'

/**
 * user服务
 */
export const UserService = {
	// 当前登录用户信息
	getCurrentInfo: function(){
		const request = new RequestParam();
		request.url = "/api/user/current/info.do";
		return HttpRequest(request);
	},
	// 通知列表
	login: function(code,info) {
		const request = new RequestParam();
		request.url = "/api/wechat/login.do?code="+code;
		request.param=info;
		request.method="POST";
		return HttpRequest(request);
	},
	// 用户收货地址
	getAddress: function() {
		const request = new RequestParam();
		request.url = "/api/address/list.do";
		return HttpRequest(request);
	},
	//用户默认的收货地址
	getDefaultAddress:function(){
		const request = new RequestParam();
		request.url = "/api/address/default.do";
		return HttpRequest(request);
	},
	// 新增收货地址
	addAddress:function(data){
		const request = new RequestParam();
		request.url = "/api/address/add.do";
		request.param=data;
		request.method="POST"
		return HttpRequest(request);
	},
	// 编辑收货地址
	editAddress:function(data){
		const request = new RequestParam();
		request.url = "/api/address/edit.do";
		request.param=data;
		request.method="POST"
		return HttpRequest(request);
	},
	// 设置默认收货地址
	settingDefault:function(addressId){
		const request = new RequestParam();
		request.url = "/api/address/setting/default.do";
		request.param={addressId:addressId};
		return HttpRequest(request);
	},
	// 删除收货地址
	removeAddress:function(addressId){
		const request = new RequestParam();
		request.url = "/api/address/remove.do";
		request.param={addressId:addressId};
		return HttpRequest(request);
	},
	bindPhone:function(data,iv){
		const request = new RequestParam();
		request.url = "/api/user/phone/decrypt.do";
		request.param={data:data,iv:iv,type:1};
		return HttpRequest(request);
	}
}
